// JavaScript Document
    $(function () {
        $.get("/xmlcache/datahandler.aspx", {
            page: "networkmasterpage",
            format: "json"
        }, function (data) {
            var salesDept = $.grep(data.Network.Departments[0].Department, function (elem, index) {
                return elem.departmentName == 'Sales';
            })[0];
            var financeDept = $.grep(data.Network.Departments[0].Department, function (elem, index) {
                return elem.departmentName == 'Finance';
            })[0];
            var internetDept = $.grep(data.Network.Departments[0].Department, function (elem, index) {
                return elem.departmentName == 'Internet';
            })[0];
            if ($('#bodyArea').hasClass('Sales')) {
				$('#customForm').attr('data-department','5');
				$('#customForm').attr('name','Sales Lead');
				$( "input[name*='DepartmentId']" ).val('5');
				$( "input[name*='FormName']" ).val('Sales Lead');
				var sunday = salesDept.Hours[0].RegularHours[0];
				var monday = salesDept.Hours[0].RegularHours[1];
				var tuesday = salesDept.Hours[0].RegularHours[2];
				var wednesday = salesDept.Hours[0].RegularHours[3];
				var thursday = salesDept.Hours[0].RegularHours[4];
				var friday = salesDept.Hours[0].RegularHours[5];
				var saturday = salesDept.Hours[0].RegularHours[6];
				$('.sun .open').text(sunday .openTime);
				$('.sun .close').text(sunday .closeTime);
				$('.mon .open').text(monday .openTime);
				$('.mon .close').text(monday .closeTime);
				$('.tue .open').text(tuesday .openTime);
				$('.tue .close').text(tuesday .closeTime);
				$('.wed .open').text(wednesday .openTime);
				$('.wed .close').text(wednesday .closeTime);
				$('.thu .open').text(thursday .openTime);
				$('.thu .close').text(thursday .closeTime);
				$('.fri .open').text(friday .openTime);
				$('.fri .close').text(friday .closeTime);
				$('.sat .open').text(saturday .openTime);
				$('.sat .close').text(saturday .closeTime);
                $('#image').html('<img src="http://assets.clickmotive.com/designs/DealerElite/Sales.jpg">')
                $('#blurb h5').html('Our Honda Sales Department Puts The Customer First...')
                $('#blurb p').html('Our Sales Department has a tradition of providing our Customers with the highest level of Professionalism, Service and Integrity. We are proud to be known as a Dealership that does things the Right Way. If you are in the market for a <a href="/area/for-sale/new">New</a> or <a href="/area/for-sale/used">Used</a> Vehicle, please give us a call <span class="phone">&nbsp;</span> , and we will be happy to assist You.');
                $('.department').text(salesDept.departmentName);
                $('.phone').text(salesDept.phoneNumber);
                $('h3.tag').text('100% Committed To Customer Satisfaction');
            }
            if ($('#bodyArea').hasClass('Finance')) {
				$('#customForm').attr('data-department','7');
				$('#customForm').attr('name','Finance Lead');
				$( "input[name*='DepartmentId']" ).val('7');
				$( "input[name*='FormName']" ).val('Finance Lead');
				var sunday = financeDept.Hours[0].RegularHours[0];
				var monday = financeDept.Hours[0].RegularHours[1];
				var tuesday = financeDept.Hours[0].RegularHours[2];
				var wednesday = financeDept.Hours[0].RegularHours[3];
				var thursday = financeDept.Hours[0].RegularHours[4];
				var friday = financeDept.Hours[0].RegularHours[5];
				var saturday = financeDept.Hours[0].RegularHours[6];
				$('.sun .open').text(sunday .openTime);
				$('.sun .close').text(sunday .closeTime);
				$('.mon .open').text(monday .openTime);
				$('.mon .close').text(monday .closeTime);
				$('.tue .open').text(tuesday .openTime);
				$('.tue .close').text(tuesday .closeTime);
				$('.wed .open').text(wednesday .openTime);
				$('.wed .close').text(wednesday .closeTime);
				$('.thu .open').text(thursday .openTime);
				$('.thu .close').text(thursday .closeTime);
				$('.fri .open').text(friday .openTime);
				$('.fri .close').text(friday .closeTime);
				$('.sat .open').text(saturday .openTime);
				$('.sat .close').text(saturday .closeTime);
                $('#image').html('<img src="http://assets.clickmotive.com/designs/DealerElite/Finance.jpg">')
                $('#blurb h5').html('Looking To Finance Your Next <span class="make"></span> near <span class="area"></span>?')
                $('#blurb p').html('Our Finance Team is committed to helping our Customers with their Credit Approval needs. Our Dealership has access to millions of dollars of credit from a variety of Lending Sources, and as a result, we are able to provide you with more options. Good Credit, Bad Credit, No Credit... We are here to help! Call one of our Finance Managers today, <span class="phone"></span>.');
                $('.button').show();
                $('.department').text(financeDept.departmentName);
                $('.phone').text(financeDept.phoneNumber);
                $('h3.tag').text('Get Pre-Approved Today');
            }
            if ($('#bodyArea').hasClass('Internet')) {
				$('#customForm').attr('data-department','12');
				$('#customForm').attr('name','Internet Lead');
				
				var sunday = internetDept.Hours[0].RegularHours[0];
				var monday = internetDept.Hours[0].RegularHours[1];
				var tuesday = internetDept.Hours[0].RegularHours[2];
				var wednesday = internetDept.Hours[0].RegularHours[3];
				var thursday = internetDept.Hours[0].RegularHours[4];
				var friday = internetDept.Hours[0].RegularHours[5];
				var saturday = internetDept.Hours[0].RegularHours[6];
				$('.sun .open').text(sunday .openTime);
				$('.sun .close').text(sunday .closeTime);
				$('.mon .open').text(monday .openTime);
				$('.mon .close').text(monday .closeTime);
				$('.tue .open').text(tuesday .openTime);
				$('.tue .close').text(tuesday .closeTime);
				$('.wed .open').text(wednesday .openTime);
				$('.wed .close').text(wednesday .closeTime);
				$('.thu .open').text(thursday .openTime);
				$('.thu .close').text(thursday .closeTime);
				$('.fri .open').text(friday .openTime);
				$('.fri .close').text(friday .closeTime);
				$('.sat .open').text(saturday .openTime);
				$('.sat .close').text(saturday .closeTime);
                $('#image').html('<img src="http://assets.clickmotive.com/designs/DealerExtreme/Internet.jpg">')
                $('#blurb h5').html('Save Time & Money With Our <span class="make"></span> Internet Department...')
                $('#blurb p').html('Our Internet Department is here to help! We know you value your time and money, so we will make every effort to assist you with your online shopping needs. ');
                $('.department').text(internetDept.departmentName);
                $('.phone').text(internetDept.phoneNumber);
                $('h3.tag').text('Let Us Do The Work For You');
            }
            $('.dealer').text(data.Network.landingPageName);
            $('.make').text(data.Network.Research[0].Makes[0].Make[0].make);
            $('.area').text(data.Network.area);
            $('.addr').text(data.Network.address);
            $('.city').text(data.Network.city);
            $('.state').text(data.Network.state);
            $('.zip').text(data.Network.zipCode);
        });
   });
	$(window).load(function(){
		if ($('.sun .open').text() == 'Closed') {
			$('.sun .dash').remove();
		}
		if ($('#bodyArea').hasClass('Finance')) {
			$( "input[name*='DepartmentId']" ).val('7');
				$( "input[name*='FormName']" ).val('Finance Lead');
		}
		if ($('#bodyArea').hasClass('Sales')) {
			$( "input[name*='DepartmentId']" ).val('5');
				$( "input[name*='FormName']" ).val('Sales Lead');
		}
		if ($('#bodyArea').hasClass('Internet')) {
			$( "input[name*='DepartmentId']" ).val('12');
				$( "input[name*='FormName']" ).val('Internet Lead');
		}
   });